package com.msos.service.phoneAddService;

import com.msos.dao.phoneAddDao.phoneAddDao;
import com.msos.dao.sendMsgDao.sendMsgDao;
import com.msos.model.customer.Customer;
import com.msos.utils.CommonsUtils;

import java.sql.SQLException;

public class phoneAddService {
    phoneAddDao phoneaddDao=new phoneAddDao();
    sendMsgDao sendMsgdao=new sendMsgDao();
    //1.判断该手机号用户是否存在
    //2.发送信息
    public Integer phoneAdd(Customer customer) {
        Integer r1=-1;
        Customer c=null;
        try {
            c = sendMsgdao.getCustomerByPho(customer.getPhone());
            System.out.println("customer==x===="+c);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        if(c!=null){
            return CommonsUtils.FAIL;
        }

        try {
            r1 = phoneaddDao.addPhone(customer);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return r1==CommonsUtils.SUCCESS?CommonsUtils.SUCCESS:CommonsUtils.FAIL;
    }

}
